<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>暗黑科技弹幕墙</title>
  <style>
    body {
      margin: 0;
      font-family: "Consolas", monospace;
      background: linear-gradient(135deg, #000000, #434343);
      color: #fff;
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .video-container {
      position: relative;
      width: 90%;
      height: 90%;
      overflow: hidden;
      border: 3px solid #00ffc8;
      border-radius: 12px;
      box-shadow: 0 0 20px #00ffc8, 0 0 40px rgba(0,255,200,0.5);
      animation: neonGlow 3s infinite alternate;
    }
    @keyframes neonGlow {
      from {
        box-shadow: 0 0 15px #00ffc8, 0 0 30px rgba(0,255,200,0.4);
      }
      to {
        box-shadow: 0 0 25px #00ffc8, 0 0 60px rgba(0,255,200,0.8);
      }
    }
    .barrage {
      position: absolute;
      white-space: nowrap;
      font-size: 18px;
      padding: 6px 10px;
      background: rgba(0, 255, 200, 0.1);
      border: 1px solid #00ffc8;
      border-radius: 4px;
      color: #00ffc8;
      animation: moveLeft 9s linear;
    }
    @keyframes moveLeft {
      from { right: -200px; }
      to { right: 100%; }
    }
    .input-box {
      position: absolute;
      bottom: 20px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      gap: 10px;
    }
    .input-box input {
      padding: 10px;
      border-radius: 4px;
      border: 1px solid #00ffc8;
      background: #111;
      color: #00ffc8;
      width: 250px;
    }
    .input-box button {
      padding: 10px 20px;
      border: 1px solid #00ffc8;
      border-radius: 4px;
      background: #111;
      color: #00ffc8;
      cursor: pointer;
      transition: 0.3s;
    }
    .input-box button:hover {
      background: #00ffc8;
      color: #111;
    }
  </style>
</head>
<body>
  <div class="video-container" id="videoContainer">
    <div class="input-box">
      <input type="text" id="barrageInput" placeholder="输入弹幕...">
      <button onclick="handleInput()">发射</button>
    </div>
  </div>
  <script>
    const container = document.getElementById('videoContainer');

    // 核心函数：生成弹幕
    function sendBarrage(text) {
      const span = document.createElement('span');
      span.className = 'barrage';
      span.style.top = Math.random() * 80 + '%';
      span.innerText = "> " + text;
      container.appendChild(span);
      setTimeout(() => container.removeChild(span), 9000);
    }

    // 处理输入框按钮
    function handleInput() {
      const input = document.getElementById('barrageInput');
      const text = input.value.trim();
      if (!text) return;
      sendBarrage(text);
      input.value = '';
    }

    // 初始示例弹幕
    function initBarrages() {
      const demoTexts = [
        "系统启动中...",
        ">> 黑暗代码已接管",
        "⚡ 数据流动如影随形",
        ">>> Welcome to the Matrix",
        "终端信号已锁定",
        "虚拟与现实的边界模糊中..."
      ];
      demoTexts.forEach((t, i) => {
        setTimeout(() => sendBarrage(t), i * 1500);
      });
    }

    // 页面加载时触发
    window.onload = initBarrages;
  </script>
</body>
</html>
